<template>
    <div class="white-search-bar"></div>
</template>

<script>

export default {
  data () {
    return {
			text: '',
			text1: '',
			arr: [],
			arr1: [],
			arr2: []
    }
  },
  created() {
		this.text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		this.strLength(this.text)
		this.text = "The full name of China is the People's Republic of China.";
		this.strIndexOf(this.text)
		this.text = "The full name of China is the People's Republic of China.";
		this.strLastIndexOf(this.text)
		this.text = "The full name of China is the People's Republic of China.";
		this.strSearch(this.text)
		this.text = "Apple, Banana, Mango";
		this.strSlice(this.text)
		this.text = "Apple, Banana, Mango";
		this.strSubstring(this.text)
		this.text = "Apple, Banana, Mango";
		this.strSubstr(this.text)
		this.text = "Please visit Microsoft!";
		this.strReplace(this.text)
		this.text = "Hello World!";
		this.strToUpperCase(this.text)
		this.text = "Hello World!";
		this.strToLowerCase(this.text)
		this.text = "Hello";
		this.text1 = " World!";
		this.strConcat(this.text, this.text1)
		this.text = "HELLO WORLD";
		this.strCharAt(this.text)
		this.text = "HELLO WORLD";
		this.strCharCodeAt(this.text)
		this.text = "a,b,c,d,e";
		this.strSplit(this.text)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrToString(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrJoin(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrPop(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrPush(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrShift(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrUnshift(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrLength(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrDelete(this.arr)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrSplice(this.arr)
		this.arr = ["Cecilie", "Lone"];
		this.arr1 = ["Emil", "Tobias", "Linus"];
		this.arr2 = ["Robin", "Morgan"];
		this.arrConcat(this.arr, this.arr1, this.arr2)
		this.arr = ["Banana", "Orange", "Apple", "Mango"];
		this.arrSlice(this.arr)
  },
  methods: {
		// length
		strLength (str) {
			console.log('length');
			console.log(str.length);
		},
		// indexOf
		strIndexOf (str) {
			console.log('indexOf 未找到返回-1 可设置第二个参数值为起始位置');
			console.log(str.indexOf('China'));
		},
		// lastIndexOf
		strLastIndexOf (str) {
			console.log('lastIndexOf 未找到返回-1 可设置第二个参数值为起始位置');
			console.log(str.lastIndexOf('China'));
		},
		// search
		strSearch (str) {
			console.log('search 未找到返回-1 没有第二个参数，但可查找正则');
			console.log(str.search('China'));
		},
		// slice
		strSlice (str) {
			console.log('slice 提取部分字符串,如果某个参数为负，则从字符串的结尾开始计数,如果省略第二个参数，则该方法将裁剪字符串的剩余部分');
			console.log(str.slice(7, 13));
			console.log(str.slice(7));
			console.log(str.slice(-13));
		},
		// substring
		strSubstring (str) {
			console.log('substring 类似于 slice()。不同之处在于 substring() 无法接受负的索引。');
			console.log(str.substring(7, 13));
		},
		// substr
		strSubstr (str) {
			console.log('substr 类似于 slice()。不同之处在于第二个参数规定被提取部分的长度。如果省略第二个参数，则该 substr() 将裁剪字符串的剩余部分。如果首个参数为负，则从字符串的结尾计算位置。第二个参数不能为负，因为它定义的是长度');
			console.log(str.substr(7, 6));
		},
		// replace
		strReplace (str) {
			console.log('replace 用另一个值替换在字符串中指定的值,不会改变调用它的字符串。它返回的是新字符串。对大小写敏感。因此不对匹配 MICROSOFT');
			console.log(str.replace("Microsoft", "MacOS"));
		},
		// toUpperCase
		strToUpperCase (str) {
			console.log('toUpperCase 字符串转换为大写');
			console.log(str.toUpperCase());
		},
		// toLowerCase
		strToLowerCase (str) {
			console.log('toLowerCase 字符串转换为小写');
			console.log(str.toLowerCase());
		},
		// concat
		strConcat (str, str1) {
			console.log('concat 连接两个或多个字符串');
			console.log(str.concat(str1));
		},
		// charAt
		strCharAt (str) {
			console.log('charAt 返回字符串中指定下标（位置）的字符串');
			console.log(str.charAt(0));
		},
		// charCodeAt
		strCharCodeAt (str) {
			console.log('charCodeAt 返回字符串中指定索引的字符 unicode 编码');
			console.log(str.charCodeAt(0));
		},
		// split
		strSplit (str) {
			console.log('split 字符串转换为数组');
			console.log(str.split(0));
		},
		// 数组
		// arrToString
		arrToString (arr) {
			console.log('toString 把数组转换为字符串');
			console.log(arr.toString());
		},
		// join
		arrJoin (arr) {
			console.log('join 把数组转换为字符串,可以规定分隔符');
			console.log(arr.join('*'));
		},
		// pop
		arrPop (arr) {
			console.log('pop 从数组中删除最后一个元素')
			console.log(arr.pop());
		},
		// push
		arrPush (arr) {
			console.log('push 在数组结尾处向数组添加一个新的元素')
			arr.push("Kiwi")
			console.log(arr);
		},
		// shift
		arrShift (arr) {
			console.log('shift 删除首个数组元素，并把所有其他元素“位移”到更低的索引')
			console.log(arr.shift());
		},
		// unshift
		arrUnshift (arr) {
			console.log('unshift 在开头向数组添加新元素，并“反向位移”旧元素')
			arr.unshift("Lemon")
			console.log(arr);
		},
		// length
		arrLength (arr) {
			console.log('length 向数组追加新元素')
			arr[arr.length] = "Kiwi";
			console.log(arr)
		},
		// delete
		arrDelete (arr) {
			console.log('delete 运算符来删除元素，改为undefined')
			delete arr[0];
			console.log(arr)
		},
		// splice
		arrSplice (arr) {
			console.log('splice 可用于向数组添加新项,第一个参数（2）定义了应添加新元素的位置（拼接）,第二个参数（0）定义应删除多少元素,其余参数（“Lemon”，“Kiwi”）定义要添加的新元素')
			arr.splice(2, 0, "Lemon", "Kiwi");
			console.log(arr)
			console.log('splice 数组中不留“空洞”的情况下移除元素,第一个参数（0）定义新元素应该被添加（接入）的位置,第二个参数（1）定义应该删除多个元素,其余参数被省略。没有新元素将被添加')
			arr.splice(0, 1);
			console.log(arr)
		},
		// concat
		arrConcat (arr, arr1, arr2) {
			console.log('concat 合并（连接）现有数组来创建一个新数组')
			console.log(arr.concat(arr1, arr2));
		},
		// slice
		arrSlice (arr) {
			console.log('用数组的某个片段切出新数组')
			console.log(arr.slice(1))
		}
  }, 
}
</script>

<style scoped>
</style>
